package com.xyzq.reks.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "account")
public class Account extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3775203519698194366L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@Column(unique = true, nullable = false)
	private Long account;
	private String name;
	private String bank;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "Fk_STAFF_STAFF", nullable = false)
	private Staff staff;
	@Temporal(TemporalType.DATE)
	@Column(name = "open_day")
	private Date openDay;
	private String transfer;
	private String remark;
	@Column(name = "paper_sh_number")
	private String paperShNumber;
	@Temporal(TemporalType.DATE)
	@Column(name = "paper_sh_openday")
	private Date paperShOpenDay;
	@Column(name = "paper_sz_number")
	private String paperSzNumber;
	@Temporal(TemporalType.DATE)
	@Column(name = "paper_sz_openday")
	private Date paperSzOpenDay;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time")
	private Date createTime;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_modify_time")
	private Date lastModifyTime;
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountMoney> moneys = new HashSet<AccountMoney>();
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountFund> funds = new HashSet<AccountFund>();
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountPaper> papers = new HashSet<AccountPaper>();
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountProfit> profits = new HashSet<AccountProfit>();
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountReward> rewards = new HashSet<AccountReward>();
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountSpecial> specials = new HashSet<AccountSpecial>();
	@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
	private Set<AccountAssert> asserts = new HashSet<AccountAssert>();

	public Long getId() {
		return id;
	}

	public Long getAccount() {
		return account;
	}

	public String getName() {
		return name;
	}

	public String getBank() {
		return bank;
	}

	public Staff getStaff() {
		return staff;
	}

	public Date getOpenDay() {
		return openDay;
	}

	public String getTransfer() {
		return transfer;
	}

	public String getRemark() {
		return remark;
	}

	public String getPaperShNumber() {
		return paperShNumber;
	}

	public Date getPaperShOpenDay() {
		return paperShOpenDay;
	}

	public String getPaperSzNumber() {
		return paperSzNumber;
	}

	public Date getPaperSzOpenDay() {
		return paperSzOpenDay;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public Date getLastModifyTime() {
		return lastModifyTime;
	}

	public Set<AccountMoney> getMoneys() {
		return moneys;
	}

	public Set<AccountFund> getFunds() {
		return funds;
	}

	public Set<AccountPaper> getPapers() {
		return papers;
	}

	public Set<AccountProfit> getProfits() {
		return profits;
	}

	public Set<AccountReward> getRewards() {
		return rewards;
	}

	public Set<AccountSpecial> getSpecials() {
		return specials;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setAccount(Long account) {
		this.account = account;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	public void setOpenDay(Date openDay) {
		this.openDay = openDay;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setPaperShNumber(String paperShNumber) {
		this.paperShNumber = paperShNumber;
	}

	public void setPaperShOpenDay(Date paperShOpenDay) {
		this.paperShOpenDay = paperShOpenDay;
	}

	public void setPaperSzNumber(String paperSzNumber) {
		this.paperSzNumber = paperSzNumber;
	}

	public void setPaperSzOpenDay(Date paperSzOpenDay) {
		this.paperSzOpenDay = paperSzOpenDay;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public void setLastModifyTime(Date lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}

	public void setTransfer(String transfer) {
		this.transfer = transfer;
	}

	public void setMoneys(Set<AccountMoney> moneys) {
		this.moneys = moneys;
	}

	public void setFunds(Set<AccountFund> funds) {
		this.funds = funds;
	}

	public void setPapers(Set<AccountPaper> papers) {
		this.papers = papers;
	}

	public void setProfits(Set<AccountProfit> profits) {
		this.profits = profits;
	}

	public void setRewards(Set<AccountReward> rewards) {
		this.rewards = rewards;
	}

	public void setSpecials(Set<AccountSpecial> specials) {
		this.specials = specials;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Account other = (Account) obj;
		if (account == null) {
			if (other.account != null)
				return false;
		} else if (!account.equals(other.account))
			return false;
		if (bank == null) {
			if (other.bank != null)
				return false;
		} else if (!bank.equals(other.bank))
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (lastModifyTime == null) {
			if (other.lastModifyTime != null)
				return false;
		} else if (!lastModifyTime.equals(other.lastModifyTime))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (openDay == null) {
			if (other.openDay != null)
				return false;
		} else if (!openDay.equals(other.openDay))
			return false;
		if (paperShNumber == null) {
			if (other.paperShNumber != null)
				return false;
		} else if (!paperShNumber.equals(other.paperShNumber))
			return false;
		if (paperShOpenDay == null) {
			if (other.paperShOpenDay != null)
				return false;
		} else if (!paperShOpenDay.equals(other.paperShOpenDay))
			return false;
		if (paperSzNumber == null) {
			if (other.paperSzNumber != null)
				return false;
		} else if (!paperSzNumber.equals(other.paperSzNumber))
			return false;
		if (paperSzOpenDay == null) {
			if (other.paperSzOpenDay != null)
				return false;
		} else if (!paperSzOpenDay.equals(other.paperSzOpenDay))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (staff == null) {
			if (other.staff != null)
				return false;
		} else if (!staff.equals(other.staff))
			return false;
		if (transfer == null) {
			if (other.transfer != null)
				return false;
		} else if (!transfer.equals(other.transfer))
			return false;
		return true;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((account == null) ? 0 : account.hashCode());
		result = prime * result + ((bank == null) ? 0 : bank.hashCode());
		result = prime * result
				+ ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result
				+ ((lastModifyTime == null) ? 0 : lastModifyTime.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((openDay == null) ? 0 : openDay.hashCode());
		result = prime * result
				+ ((paperShNumber == null) ? 0 : paperShNumber.hashCode());
		result = prime * result
				+ ((paperShOpenDay == null) ? 0 : paperShOpenDay.hashCode());
		result = prime * result
				+ ((paperSzNumber == null) ? 0 : paperSzNumber.hashCode());
		result = prime * result
				+ ((paperSzOpenDay == null) ? 0 : paperSzOpenDay.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result + ((staff == null) ? 0 : staff.hashCode());
		result = prime * result
				+ ((transfer == null) ? 0 : transfer.hashCode());
		return result;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this,
				ToStringStyle.DEFAULT_STYLE);
		builder.append("id", id);
		builder.append("account", account);
		builder.append("name", name);
		builder.append("bank", bank);
		builder.append("staff", staff);
		builder.append("openDay", openDay);
		builder.append("transfer", transfer);
		builder.append("remark", remark);
		builder.append("paperShNumber", paperShNumber);
		builder.append("paperShOpenDay", paperShOpenDay);
		builder.append("paperSzNumber", paperSzNumber);
		builder.append("paperSzOpenDay", paperSzOpenDay);
		builder.append("createTime", createTime);
		builder.append("lastModifyTime", lastModifyTime);
		return builder.toString();
	}

	public void setAsserts(Set<AccountAssert> asserts) {
		this.asserts = asserts;
	}

	public Set<AccountAssert> getAsserts() {
		return asserts;
	}
}
